package com.ybkj.daijia.server.event.listener.zhuan;

import com.ybkj.daijia.server.event.model.zhuan.SaveLocationEvent;
import com.ybkj.daijia.server.model.OrderLocationMany;
import com.ybkj.daijia.server.service.OrderLocationManyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

/**
 * @author zhyu
 * @date 2019-09-24 17:48:26
 */
@Component
@EnableAsync
public class SaveLocationEvenListener implements ApplicationListener<SaveLocationEvent> {

    private static final Logger logger = LoggerFactory.getLogger(SaveLocationEvenListener.class);

    @Autowired
    private OrderLocationManyService orderLocationManyService;


    @Async
    @Override
    public void onApplicationEvent(SaveLocationEvent event) {
        OrderLocationMany orderLocation_dr_ca = event.getOrderLocation_dr_ca();
        OrderLocationMany orderLocation_pa = event.getOrderLocation_pa();
        OrderLocationMany orderLocationMany = event.getOrderLocationMany();
        OrderLocationMany orderLocationMany_dr = event.getOrderLocationMany_dr();

        orderLocationManyService.save(orderLocation_pa);
        orderLocationManyService.save(orderLocation_dr_ca);
        orderLocationManyService.save(orderLocationMany);
        orderLocationManyService.save(orderLocationMany_dr);
        logger.error("locations save ok --");
    }
}
